// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license

@import "../../global-navigation/mixins/index";
@import "../mixins/index";

/**
 * @summary Subtabs
 *
 * @name sub-tabs
 * @selector .slds-sub-tabs
 * @restrict .slds-tabs_default
 * @support dev-ready
 * @variant
 */

.slds-sub-tabs .slds-tabs_default__nav {
  border-bottom-width: $border-width-thin;
}

/**
 * @summary Subtab item
 * @selector .slds-sub-tabs__item
 * @restrict .slds-sub-tabs li
 */
.slds-sub-tabs__item {
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0;

  &.slds-active,
  &.slds-is-open {
    background: $brand-primary-transparent-10;
  }

  &:after {
    content: none;
  }

  .slds-tabs_default__link:focus,
  &.slds-has-focus {
    text-decoration: underline;
  }

  + .slds-sub-tabs__item {
    margin-left: 0;
  }

  @include tab-notification-pulsing-animation;

  /**
   * @summary Success notification on a subtab
   *
   * @selector .slds-has-success
   * @restrict .slds-sub-tabs__item
   */
  &.slds-has-success {
    @include sub-tab-notification-before(var(--slds-g-color-success-base-50, #{$color-background-success-dark}),
      var(--slds-g-color-success-base-40, #{$color-background-success-darker}));

    &:before {
      animation-name: success-pulse;
    }
  }

  /**
   * @summary Error notification on a subtab
   *
   * @selector .slds-has-error
   * @restrict .slds-sub-tabs__item
   */
  &.slds-has-error {
    @include sub-tab-notification-before(var(--slds-g-color-error-base-40, #{$color-background-destructive}),
      var(--slds-g-color-error-base-30, #{$color-background-destructive-active}));

    &:before {
      animation-name: error-pulse;
    }
  }

  &.slds-has-success,
  &.slds-has-error {
    color: var(--slds-g-color-neutral-base-100, #{$color-gray-1});

    .slds-indicator_unread {
      background-color: var(--slds-g-color-neutral-base-100, #{$color-gray-1});
    }

    .slds-indicator_unsaved {
      color: var(--slds-g-color-neutral-base-100, #{$color-gray-1});
    }
  }

  /**
   * @summary Warning notification on a subtab
   *
   * @selector .slds-has-warning
   * @restrict .slds-sub-tabs__item
   */
  &.slds-has-warning {
    @include sub-tab-notification-before(var(--slds-g-color-warning-base-60, #{$color-background-warning}), var(--slds-g-color-warning-base-70, #{$color-background-warning-dark}));
    --slds-c-icon-color-foreground: var(--slds-g-color-neutral-base-10, #{$color-text-icon-default});
    color: var(--slds-g-color-neutral-base-10, currentColor);

    &:before {
      animation-name: warning-pulse;
    }

    .slds-indicator_unread {
      background-color: currentColor;
    }

    .slds-indicator_unsaved {
      color: currentColor;
    }
  }
}

.slds-has-pinned-regions {

  .slds-sub-tabs__item {

    &.slds-active,
    &.slds-is-open {

      &:before {
        content: '';
        height: 3px;
        display: block;
        background: $brand-primary;
        position: absolute;
        top: 0;
        left: -1px;
        right: -1px;
      }
    }
  }
}
